<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .count{
            display: inline-block;
            width: 200px;
            height: 200px;
            border-radius: 50%;
            background: pink;

            text-align: center;
            line-height: 200px;
            font-size: 50px;
            font-weight: bolder;
        }
    </style>
</head>
<body>
    <div id="app">
        <v-count class="count" :count="count" @add="add"></v-count>
        <v-count class="count" :count="count" @add="add"></v-count>
    </div>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/lodash.js/4.17.21/lodash.min.js"></script>
<script src="../../js/vue.js"></script>
<script>
    Vue.config.productionTip=false;
    new Vue({
        el:"#app",
        data:{
            count:{flag:0}
        },
        methods:{
          add({name,step}){
              if(name==="v-count"){
                  this.count.flag+=step
              }
          }
        },
        components:{
            "v-count":{
                props:["count"],
                template:`<span @click="add">{{count.flag}}</span>`,
                methods:{
                    add(){
                        //子向父的数据传递(通过vue自定义事件)
                        this.$emit("add",{name:"v-count",step:2})
                    }
                }
            }
        }
    })
</script>
</html>